

#include <stdio.h>
#include <conio.h>
#include <math.h>

double f(float x)
{
    double tri ;
    double y;
	return x;
    y = -x*x ;
    tri = exp(y) ;
    return tri ;
}
double tinhTichPhan()
{
    int i , m , n ;
    double a , b , h ,epslon ;
    double s0 , s1 , s2 , i1 , i2;
   int t ;
	a=0;
	b=1;
	epslon=0.1;
    s1 = 0;
    s2 = 0;
    n = 1 ;
    h = b - a ;
    s0 = f(a) + f(b) ;
    i2 = h*s0/2.0 ;
    t = 0 ;
    do
    {
        i1 = i2 ;
        s1 +=s2 ;
        m = 2*n ;
        h /=2 ;
        s2 = 0 ;
        for (i = 1 ; i <= n ;i++)   s2 +=f( a + (2*i -1)*h ) ;
        n = m ;
        i2 = h*(s0 + 2*s1 + 2*s2)/2.0 ;
        if ( fabs(i2 - i1) < epslon )
        {
            t = 1 ;
           return i2;
        }
    } while (!t) ;
	
}
double tinhNghiemXapXi(float xmin,float xmax,int sopthh,double pVal,double qVal,double fVal,float xi,int nGauss)
{

return 0;
}
void main()
{
 printf("Gia tri %12.3lf",tinhTichPhan());
 getch();

}
